import { getVisitorDetailApi } from '@/api/custcare/visitor/visitor'
import { VisitorParam } from '@/api/custcare/visitor/VisitorModel'
import { StatusCode } from '@/http/request'
import { DialogModel } from '@/types/BaseType'
import { reactive } from 'vue'

export default function useVisitorDetail(
    dialogModel: DialogModel,
    onShow: any,
    onClose: any
) {
    const onConfirm = () => {
        onClose()
    }

    const visitor = reactive({
        data: {},
        detail: {}
    })

    // 展示弹框
    const show = async (type: string, id: number) => {
        dialogModel.title = '访客详情'

        let res = await getVisitorDetailApi(
            reactive<VisitorParam>({
                id: id
            })
        )
        if (res && res.code == StatusCode.Success) {
            visitor.data = res.data
            visitor.detail = res.data.detail
        }

        // 显示弹框
        onShow()
    }

    return {
        onConfirm,
        show,
        visitor
    }
}
